from django.http import HttpResponseRedirect
from legendofkrouzt.personagem.models import Personagem

def not_login(f):
    def certificar(request, *args, **kwargs):
        if(request.user.is_authenticated()):
            return HttpResponseRedirect('/')
        return f(request, *args, **kwargs)
    certificar.__doc__ = f.__doc__
    certificar.__name__ = f.__name__
    return certificar

def not_character(f):
    def certificar(request, *args, **kwargs):
        if(not request.session.get('id_Personagem')):
            return HttpResponseRedirect('/personagem/')
        return f(request, *args, **kwargs)
    certificar.__doc__ = f.__doc__
    certificar.__name__ = f.__name__
    return certificar